package com.hmall.trade.listener;

import com.hmall.trade.service.IOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class tradeSuccess {
    private final IOrderService iOrderService;


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name ="trade.pay.sucess.queue"),
            exchange = @Exchange(name = "pay.topic"),
            key = "pay.sucess"
    ))
    public void tradeSuccess(Long orderId){

        iOrderService.markOrderPaySuccess(orderId);
    }
}
